package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);not null;unique;comment:用户名"json:"username"`
	Password string `gorm:"type:varchar(32);not null"json:"password"`
}

func (u *User) Creat() error {
	return DB.Create(&u).Error
}
func (u *User) GetInitByUsername(username string) error {
	return DB.Where("username=?", username).Limit(1).Find(&u).Error
}
func (u *User) List() (users []*User, err error) {
	err = DB.Find(&u).Error
	return
}
